
/**
 *
 *
 */

package main
import (
	"os"
	"flag"
	"fmt"
)

var omitNewline =flag.Bool("n",false,"don't print final newline");

const(
	Space=" "
	Newline="\n2"
)


func flagTest(){
	flag.Parse()
	var s string="";
	for i:=0;i<flag.NArg();i++{
		if i>0{
			s+=Space
		}
		s+=flag.Arg(i)
	}
	
	if!*omitNewline{
		s+=Newline
	}
	os.Stdout.WriteString(s);
}


func inputTest(){
	
	
	input:=make([]byte,1024)
	os.Stdin.Read(input)
	fmt.Printf("Hello World");
    println(string(input[0:len(input)-1]))
}


func arrayTest(array []int){
	
	sum:=0
	for i:=0;i<len(array);i++{
		if array[i]==0{
			array[i]=i
		}
		sum+=array[i]
		
		println(i,"=",array[i]," ");
	}
	println("sum=",sum)
	
}


func stringTest(){
	
	str:="hello"
	if(str[0]!='h'){
		os.Exit(1)
	}
	str="world"
	fmt.Printf(str)
	var str2 *string=&str
	*str2="hello world"
	fmt.Printf(str)
}


func forTest(){
	
	a:=map[string]int{"num1":20,"num2":30,"num3":40}
	for i,v:=range a{
		//ForEach 方式遍历Map
		println(i);
		println(v);
	}
}
func NoClose(){
	input:=make([]byte,1024)
	os.Stdin.Read(input)
	
}
func main(){
//	stringTest()
//	forTest()
	arrayTest([]int{1,2,3,4,5,6,7,8,9}[3:7])//切片数组，截取数组的一部分，传参
	NoClose()
	println(3434)
}


